package com.bbms.dao.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Repository;
import com.bbms.dao.ReaderCategoryDao;
import com.bbms.entity.Page;
import com.bbms.entity.ReaderCtaegory;
import com.bbms.util.HibernateUtil;

/**
 * 
 * @author Administrator
 *读者类型数据管理实现类
 */
@Repository("ReaderCategoryDaoImpl")
public class ReaderCategoryDaoImpl implements ReaderCategoryDao{

	/**
	 * 保存读者类型
	 */
	@Override
	public void save(ReaderCtaegory t) {
		HibernateUtil.save(t);
	}

	/**
	 * 更新读者类型
	 */
	@Override
	public void update(ReaderCtaegory t) {
		HibernateUtil.update(t);
	}

	/**
	 * 删除读者类型
	 */
	@Override
	public void delete(ReaderCtaegory t) {
	    HibernateUtil.delete(t);
	}

	/**
	 * 获取分页数据（分页查询）
	 */
	@Override
	public Page getPage(int currentPage, int pageSize) {
		Page page = new Page();
		DetachedCriteria dc = DetachedCriteria.forClass(ReaderCtaegory.class);
		page = HibernateUtil.getPage(dc, currentPage, pageSize);
		return page;
	}

	/**
	 * 获取所有数据（不分页）
	 */
	@Override
	public List<?> query() {
		
		DetachedCriteria dc = DetachedCriteria.forClass(ReaderCtaegory.class);
		List<?> list = HibernateUtil.query(dc);
		
		return list;
	}

}
